package cn.thoughtworks.school.contract;

import cn.thoughtworks.school.Application;
import cn.thoughtworks.school.entities.SimpleCodingSubmission;
import cn.thoughtworks.school.handlers.BusinessException;
import cn.thoughtworks.school.services.SimpleCodingSubmissionService;
import com.github.database.rider.core.api.configuration.DBUnit;
import com.github.database.rider.core.api.dataset.DataSet;
import com.github.database.rider.spring.api.DBRider;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;

@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@ActiveProfiles("test")
@Transactional
@DBRider
@DBUnit(caseSensitiveTableNames = true)
@DataSet("simplecodingquizsubmissions.yml")
public class SimpleCodingQuizSubmissionBase {
    @Autowired
    private WebApplicationContext wac;
    @MockBean
    private SimpleCodingSubmissionService simpleCodingSubmissionService;
    @Before
    public void setup() throws BusinessException {

        when(simpleCodingSubmissionService.judgeCodingQuiz(any())).thenReturn(new SimpleCodingSubmission(1L, 1L, 1L, "https://github.com/tws-online-quiz/java-collection-operator.git",2,"正在初始化,正在上传仓库地址,正在检查答案格式","master" , "https://s3.cn-north-1.amazonaws.com.cn/quiz-center-files/user-answer/1543385552729-8c03deb9-728e-43b1-b8a8-bc1c42cbfe2b.zip" ));
        RestAssuredMockMvc.webAppContextSetup(wac);
    }
}
